package HomeWork.AdvancedStream;

import java.io.*;

/**
 * 用缓冲流读写文件的速度体验
 */
public class Practice01 {
    public static void main(String[] args) throws IOException {
        //搭建低级流，搭建Buffer流
        FileInputStream fis=new FileInputStream("view.jpg");
        FileOutputStream fos=new FileOutputStream("view_copy.jpg");
        BufferedInputStream bis=new BufferedInputStream(fis);
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        //开始复制
        long start=System.currentTimeMillis();
        int d;
        while((d=bis.read())!=-1){
            bos.write(d);
        }
        long end=System.currentTimeMillis();
        //设置计时
        System.out.println("Finished, spent: "+(end-start)+" ms");
        //输出成功和耗时，关闭流
    }
}
